{include file="public/header" /}
<style>
    .my-upload-right{
        width: 25%;
        position: absolute;
        right: 23px;
        top: 10px;
    }
    .layui-form-item.my-width{
        width: 73%;
    }
    #uoload-thumbnail.layui-btn{
        display: none;
    }
    .layui-upload-list {
        width: 100%;
        height: 143px;
    }
    .layui-upload-list-title {
        height: 143px;
        line-height: 143px;
    }
    .xm-select-parent .xm-form-select dl {
        z-index: 99999999999;
    }
</style>
</head>
<body>
<form class="layui-form layui-form-pane" action="" style="padding: 20px;position: relative;">
    <input type="hidden" name="information_id" value="{$dataInfo.information_id|default=0}">
    {notempty name="SUBSTATIONS"}
    <input type="hidden" name="substation_id" value="{$dataInfo.substation_id|default=$SUBSTATIONS}">
    {/notempty}
    <div class="layui-form-item my-width">
        <label class="layui-form-label ">资讯标题</label>
        <div class="layui-input-block ">
            <input type="text" name="information_title"  required lay-verify="required"  placeholder="请输入资讯标题" autocomplete="off" class="layui-input" value="{$dataInfo.information_title|default=''}">
        </div>
    </div>
    <div class="layui-form-item my-width">
        <label class="layui-form-label ">标签</label>
        <div class="layui-input-inline" style="width: 50%">
            <input type="text" name="keywords"  autocomplete="off" class="layui-input" value="{$dataInfo.keywords|default=''}">
        </div>
        <button class="layui-btn" type="button" id="getKeywords">获取标签</button>
    </div>
    <div class="layui-form-item my-width">
        <label class="layui-form-label">资讯分类</label>
        <div class="layui-input-block" >
            <select name="classification_id" lay-search required lay-verify="required" placeholder="请输入资讯分类描叙" >
                <option value="">请选择</option>
                {notempty name="classificationList"}
                {volist name="classificationList" id="tl"}
                <option value="{$tl.classification_id}" {present name="dataInfo.classification_id"}{if condition="$tl['classification_id'] == $dataInfo['classification_id']"}selected{/if}{/present}>{empty name="SUBSTATIONS"}《{$tl.substation_name}》{/empty}{notempty name="$tl.level_name"}{$tl.level_name}&ensp;{/notempty}{$tl.classification_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资讯作者</label>
        <div class="layui-input-block" >
            <input type="text" name="information_author"  placeholder="请输入资讯作者" autocomplete="off" class="layui-input" value="{$dataInfo.information_author|default=''}">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">资讯置顶</label>
        <div class="layui-input-block">
            {notempty name="RadioIs"}
            {volist name="RadioIs" id="vo"}
            <input type="radio" name="is_top" value="{$key}" title="{$vo}" {present name="dataInfo.is_top"}{eq name="dataInfo.is_top" value="$key"}checked{/eq}{else/}{eq name="key" value="0"}checked{/eq}{/present}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">资讯显示</label>
        <div class="layui-input-block">
            {notempty name="RadioIs"}
            {volist name="RadioIs" id="vo"}
            <input type="radio" name="is_display" value="{$key}" title="{$vo}" {present name="dataInfo.is_display"}{eq name="dataInfo.is_display" value="$key"}checked{/eq}{else/}{eq name="key" value="1"}checked{/eq}{/present}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">SEO关键字</label>
        <div class="layui-input-block" >
            <textarea name="seo_keyword" placeholder="请输入SEO关键字" class="layui-textarea">{$dataInfo.seo_keyword|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">SEO描叙</label>
        <div class="layui-input-block">
            <textarea name="seo_description" placeholder="请输入SEO描叙" class="layui-textarea">{$dataInfo.seo_description|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">正文描叙</label>
        <div class="layui-input-block">
            <textarea name="description" placeholder="请输入正文描叙" class="layui-textarea">{$dataInfo.description|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">正文内容</label>
        <div class="layui-input-block">
            <textarea name="text_content" id="text_content" placeholder="请输入正文内容">{$dataInfo.text_content|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">专题</label>
            <div class="layui-input-block">
                <select name="keyword_id" xm-select="select7_1" xm-select-search="" xm-select-skin="primary">
                    {notempty name="keywordAll"}
                    {volist name="keywordAll" id="vo"}
                    <option value="{$vo.keyword_id}" {notempty name="dataInfo.keyword_id"}{if condition="in_array($vo['keyword_id'],$dataInfo['keyword_id'])"}selected="selected"{/if}{/notempty}>{$vo.keyword_name}</option>
                    {/volist}
                    {/notempty}
                </select>
            </div>
        </div>
    </div>
    {empty name="SUBSTATIONS"}
    <div id="substation_type">
        <div class="layui-form-item" pane>
            <label class="layui-form-label">发布网站</label>
            <div class="layui-input-block">
                {notempty name="userSubstationList"}
                {volist name="userSubstationList" id="vo"}
                <input type="radio" name="substation_id" value="{$vo.substation_id}" title="{$vo.substation_name}"  {notempty name="dataInfo.substation_id"}{if condition="$dataInfo['substation_id'] eq $vo['substation_id']"}checked{/if}{/notempty}>
                {/volist}
                {/notempty}
            </div>
        </div>
    </div>
    {/empty}
    <div class="layui-form-item my-upload-right">
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="uoload-thumbnail">上传缩略图</button>
            <input type="hidden" name="thumbnail" id="thumbnail" value="{$dataInfo.thumbnail|default=''}">
            <div class="layui-upload-list">
                <div class="layui-upload-list-title">缩略图</div>
                <img class="layui-upload-img" id="thumbnail-img" src="{$dataInfo.thumbnail|default=''}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="button" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
<script>
    var form;
    var UploadIndex;
    layui.use(['form','upload','formSelects'], function(){
        form = layui.form;
        var upload = layui.upload;
        var formSelects = layui.formSelects;
        form.render();
        //监听提交
        form.on('submit(formDemo)', function(data){
            post_sub("{:url('Informations/informationAdd')}",data.field);
            return false;
        });

        //缩略图上传
        var uploadInst = upload.render({
            elem: '#uoload-thumbnail'
            ,url: "{:url('FileOperation/uploadImg',['type'=>'InformationThumbnail'])}"
            ,before: function(obj){
                UploadIndex = layer.msg('图片上传中', {
                    icon: 16
                    ,shade: 0.01
                    ,time:0
                });
            }
            ,done: function(res){
                layer.close(UploadIndex);
                layer.msg(res.msg);
                //如果上传失败
                if(parseInt(res.code) == 0){
                    //上传成功-默认赋值
                    $("#thumbnail").val(res.url);
                    $("#thumbnail-img").attr("src",res.url);
                }
            }
        });
    });
    $(function () {
        //百度编辑器初始化
        UE.getEditor('text_content',{
            initialFrameWidth:'100%',
            initialFrameHeight: 500,
        });
        $(".layui-upload .layui-upload-list").click(function () {
            $('#uoload-thumbnail').trigger('click');
        });

        //标题关键字获取
        $("#getKeywords").click(function () {
            UploadIndex = layer.msg('请求中', {
                icon: 16
                ,shade: 0.01
                ,time:0
            });
            $.post("{:url('Other/getKeyword')}", {str:$("input[name=information_title]").val()}, function (data, status) {
                layer.close(UploadIndex);
                $("input[name=keywords]").val(data);
            });
        });
    });
</script>
</html>